package com.qfjy.suzhou;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: SUZ
 * @date:2022/9/13 19:06
 * @version: 1.0
 */
public class PersonVo {
    //列表当作数据库
    private List<Person> personList;

    //数据库中传递数据
    public  PersonVo(){
        personList=new ArrayList<Person>();
        Person person = new Person(1,"zhangsan");
        Person person1 = new Person(2, "lisi");
        personList.add(person);
        personList.add(person1);

    }

    //数据库操作
    //删除

    public  void deletePersonByPId(Integer pId){
        personList.remove(pId);
        System.out.println("pId:"+pId+",deleted from database");


    }

    //查询列表
    public List<Person> list(){

        return personList;
    }

    //查询单个
    public Person person(Integer pId){
        return personList.get(pId);
    }


    //增加

    public void addperson(Person person){
        personList.add(person);
        System.out.println("PId:"+person.getpId()+"\t"+"PName:"+person.getpName()+"\t"+"increased to database");
    }

    //更新

    public  void updatePerson(Person person){

       personList.get(person.getpId()).setpName(person.getpName());
        System.out.println("Person:"+person.getpId()+",updated in the database");



    }


}
